package com.bilibili.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bilibili.entity.CommenResult;
import com.bilibili.service.DanmakuService;
import com.bilibili.service.impl.DanmakuServiceImpl;

@WebServlet("/allDanmakuDown.do")
public class AllDanmakuDownServlet extends HttpServlet {
    DanmakuService ds = new DanmakuServiceImpl();

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("application/json;charset=utf-8");
        int countDanmaku = ds.getDanmakuCount(1); // 修正方法调用
        CommenResult result = new CommenResult();
        result.setData(countDanmaku);
        response.getWriter().write(result.toJOSNString());
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}